Create SQL database


In [22]:
import sqlite3

connect = sqlite3.connect('simple_sqlite3.db')
cursor = connect.cursor()

def tableCreate():
    cursor.execute("CREATE TABLE SAMSUNG(ID INT, datestamp TEXT, value REAL)")

Create Table (create only once)


In [23]:
tableCreate()


---------------------------------------------------------------------------
OperationalError                          Traceback (most recent call last)
<ipython-input-23-782f085c74e2> in <module>()
----> 1 tableCreate()

<ipython-input-22-a527abaf3ddc> in tableCreate()
      5 
      6 def tableCreate():
----> 7     cursor.execute("CREATE TABLE SAMSUNG(ID INT, datestamp TEXT, value REAL)")

OperationalError: table SAMSUNG already exists

Add a new entry and commit (save)


In [24]:
cursor.execute("INSERT INTO SAMSUNG VALUES(1, '2015-07-01', 50000)")
connect.commit()

In [ ]: